/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package JFrame;

import javax.swing.JOptionPane;

import lite.*;

import static lite.util.NewUser;

import mooer.*;

/**
 * @author Administrator
 */
public class SignIn extends javax.swing.JFrame {

    /**
     * Creates new form register
     */
    public SignIn() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        背景 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        头像 = new javax.swing.JLabel();
        账号输入框 = new javax.swing.JTextField();
        注册 = new javax.swing.JButton();
        登录 = new javax.swing.JButton();
        账号 = new javax.swing.JLabel();
        密码 = new javax.swing.JLabel();
        密码输入框 = new javax.swing.JPasswordField();

        jLabel1.setText( "jLabel1" );

        setDefaultCloseOperation( javax.swing.WindowConstants.EXIT_ON_CLOSE );
        setTitle( "登录" );

        背景.setIcon( new javax.swing.ImageIcon( getClass().getResource( "/backGround/b5.png" ) ) ); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( jPanel1 );
        jPanel1.setLayout( jPanel1Layout );
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addComponent( 背景, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
                                        );
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addComponent( 背景, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
                                      );

        jPanel2.setOpaque( false );

        头像.setIcon( new javax.swing.ImageIcon( getClass().getResource( "/icon/i1.gif" ) ) ); // NOI18N
        头像.setText( "那你口裂" );
        头像.setOpaque( true );

        注册.setText( "注册" );
        注册.setCursor( new java.awt.Cursor( java.awt.Cursor.HAND_CURSOR ) );
        注册.addActionListener( new java.awt.event.ActionListener() {
            public void actionPerformed( java.awt.event.ActionEvent evt ) {
                注册ActionPerformed( evt );
            }
        } );

        登录.setText( "登入" );
        登录.setCursor( new java.awt.Cursor( java.awt.Cursor.HAND_CURSOR ) );
        登录.addActionListener( new java.awt.event.ActionListener() {
            public void actionPerformed( java.awt.event.ActionEvent evt ) {
                登录ActionPerformed( evt );
            }
        } );

        账号.setFont( new java.awt.Font( "宋体", 1, 14 ) ); // NOI18N
        账号.setText( "手机号：" );
        账号.setToolTipText( "" );

        密码.setFont( new java.awt.Font( "宋体", 1, 14 ) ); // NOI18N
        密码.setText( "密码：" );

        密码输入框.setToolTipText( "" );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout( jPanel2 );
        jPanel2.setLayout( jPanel2Layout );
        jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addContainerGap( 210, Short.MAX_VALUE )
                                .addComponent( 头像, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE )
                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                        .addGroup( jPanel2Layout.createSequentialGroup()
                                                .addGap( 96, 96, 96 )
                                                .addComponent( 注册 )
                                                .addGap( 18, 18, 18 )
                                                .addComponent( 登录 ) )
                                        .addGroup( jPanel2Layout.createSequentialGroup()
                                                .addGap( 25, 25, 25 )
                                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
                                                        .addComponent( 账号 )
                                                        .addComponent( 密码 ) )
                                                .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
                                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false )
                                                        .addComponent( 账号输入框, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE )
                                                        .addComponent( 密码输入框 ) ) ) )
                                .addGap( 396, 396, 396 ) )
                                        );
        jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addGroup( jPanel2Layout.createSequentialGroup()
                                .addGap( 226, 226, 226 )
                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                        .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
                                                        .addGroup( jPanel2Layout.createSequentialGroup()
                                                                .addComponent( 账号输入框, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE )
                                                                .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED )
                                                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
                                                                        .addComponent( 密码输入框, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE )
                                                                        .addComponent( 密码 ) )
                                                                .addGap( 32, 32, 32 ) )
                                                        .addGroup( javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                                                .addGap( 11, 11, 11 )
                                                                .addComponent( 账号 )
                                                                .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ) ) )
                                                .addGroup( jPanel2Layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
                                                        .addComponent( 注册 )
                                                        .addComponent( 登录 ) ) )
                                        .addComponent( 头像 ) )
                                .addContainerGap( 224, Short.MAX_VALUE ) )
                                      );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane() );
        getContentPane().setLayout( layout );
        layout.setHorizontalGroup(
                layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addComponent( jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
                        .addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                .addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
                                 );
        layout.setVerticalGroup(
                layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                        .addComponent( jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
                        .addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                .addComponent( jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
                               );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void 登录ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_登录ActionPerformed
        String zhanghao = 账号输入框.getText();
        String mima = 密码输入框.getText();
        if( mima.equals( util.getPasswordByTel( zhanghao ) ) ){
            // TODO sign in
            Golbal.UserUid = util.getUserUidByTel( zhanghao );
            new User_Msg_Load();
            this.setVisible( false );
            new Main_UI().setVisible( true );
        }
        else{
            JOptionPane.showMessageDialog( null, "请重新输入密码", "密码错误", JOptionPane.INFORMATION_MESSAGE );
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_登录ActionPerformed

    private void 注册ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_注册ActionPerformed
        // TODO add your handling code here:
        this.setVisible( false );
        new Register().setVisible( true );

    }//GEN-LAST:event_注册ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main( String args[] ) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try{
            for( javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels() ){
                if( "Nimbus".equals( info.getName() ) ){
                    javax.swing.UIManager.setLookAndFeel( info.getClassName() );
                    break;
                }
            }
        }catch( ClassNotFoundException ex ){
            java.util.logging.Logger.getLogger( SignIn.class.getName() ).log( java.util.logging.Level.SEVERE, null, ex );
        }catch( InstantiationException ex ){
            java.util.logging.Logger.getLogger( SignIn.class.getName() ).log( java.util.logging.Level.SEVERE, null, ex );
        }catch( IllegalAccessException ex ){
            java.util.logging.Logger.getLogger( SignIn.class.getName() ).log( java.util.logging.Level.SEVERE, null, ex );
        }catch( javax.swing.UnsupportedLookAndFeelException ex ){
            java.util.logging.Logger.getLogger( SignIn.class.getName() ).log( java.util.logging.Level.SEVERE, null, ex );
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater( new Runnable() {
            public void run() {
                new SignIn().setVisible( true );
            }
        } );
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel 头像;
    private javax.swing.JLabel 密码;
    private javax.swing.JPasswordField 密码输入框;
    private javax.swing.JButton 注册;
    private javax.swing.JButton 登录;
    private javax.swing.JLabel 背景;
    private javax.swing.JLabel 账号;
    private javax.swing.JTextField 账号输入框;
    // End of variables declaration//GEN-END:variables
}
